package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.Word;
import com.qf.mapper.WordDao;
import com.qf.service.WordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 2019/12/14
 * qjh
 * springboot_oa_five
 * 面向对象面向君 不负代码不负卿
 */
@Service
public class WordServicImpl implements WordService {
    @Autowired
    private WordDao wordDao;
    @Override
    public PageInfo<Word> findAllWord(Integer page, String wordName) {
        PageHelper.startPage(page, 5);
        Map map = new HashMap();
        map.put("wordName",wordName);
        List<Word> allWord = wordDao.findAllWord(map);
        PageInfo<Word> pageInfo = new PageInfo<>(allWord);
        return pageInfo;
    }

    @Override
    public Integer bathDelete(int[] arr) {
        Integer integer = wordDao.bathDelete(arr);
        return integer;
    }

    @Override
    public List<Word> bathDaochu(int[] arr) {
        List<Word> words = wordDao.bathDaochu(arr);
        return words;
    }

    @Override
    public Integer addwenjianjia(Word word) {
        Date date = new Date();
        word.setWordTime(date);
        word.setWordSupId(0);
        word.setWordType("文件夹");
        Integer addwenjianjia = wordDao.addwenjianjia(word);
        return addwenjianjia;
    }

    @Override
    public Integer addwenjian(Word word) {
        Date date = new Date();
        word.setWordTime(date);
        Integer addwenjianjia = wordDao.addwenjianjia(word);
        return addwenjianjia;
    }

    @Override
    public List<Word> findAllWenJianJia() {
        List<Word> allWenJianJia = wordDao.findAllWenJianJia();
        return allWenJianJia;
    }

    @Override
    public List<Word> findSecondWord(Integer wordId) {
        List<Word> words = wordDao.findSecondWord(wordId);
        return words;
    }
}
